var o = require("../../../../@babel/runtime/helpers/objectSpread2");

require("../../../../@babel/runtime/helpers/Arrayincludes");

var e = getApp();

Component({
    properties: {
        plugin: {
            type: Object
        },
        isRent: {
            type: null
        },
        favorite: {
            type: null
        },
        activityid: {
            type: null
        },
        prop_goods_info: {
            type: null
        },
        isBuy: {
            type: null
        },
        isBegTime: {
            type: null
        },
        goodsType: {
            type: null
        },
        enterAt: {
            type: null
        },
        gooddatas: {
            type: null
        },
        fromStock: {
            type: null
        }
    },
    pageLifetimes: {
        show: function() {
            "hotelGoods" == this.data.goodsType && this.hotelGetData(this.data.prop_goods_info);
        }
    },
    observers: {
        "prop_goods_info,goodsType": function(o, e) {
            "hotelGoods" == e && this.hotelGetData(o);
        },
        "gooddatas,goodsType,plugin": function(o, t, i) {
            if (o) {
                if (JSON.parse(wx.getStorageSync("mailLanguage")).goods) {
                    var a = JSON.parse(wx.getStorageSync("mailLanguage")).goods;
                    this.setData({
                        goods_profit: a.goods_profit ? a.goods_profit : "利润",
                        vip_price_name: a.vip_price ? a.vip_price : "会员价"
                    });
                }
                var s = o.get_goods;
                if (s && (s.with_slogan = Boolean(s.has_one_goods_advertising && 1 == s.has_one_goods_advertising.is_open), 
                s.with_slogan && (o.get_goods.slogan = s.has_one_goods_advertising.copywriting), 
                s.member_discount && s.member_discount.discount && (e._isTextEmpty(s.member_discount.discount) ? this.setData({
                    openVip: 1
                }) : this.setData({
                    openVip: s.member_discount.discount
                }), s.member_discount.all_level_price && this.getMemLevelInfo(s)), s.available_coupon && this.setData({
                    available_coupon: s.available_coupon || []
                })), "hotelGoods" != t && "group_goods" != t && "grabGroup" != t && "retailGood" != t && "ywmGroup" != t && this.init(this.data.gooddatas), 
                "retailGood" == t) this.setData({
                    goodsInfo: o
                }); else if ("grabGroup" != t) {
                    this.setData({
                        goodsInfo: [ "group_goods", "groupwork", "ywmGroup" ].includes(t) ? o.goods_info : o.get_goods,
                        // goodsType: o.goods_type
                    });
                    
                }
            }
            i && (this.setData({
                goods_plugin: i
            }), this.setIsLove());
        }
    },
    lifetimes: {
        attached: function(o) {
            var e = wx.getStorageSync("langIndex"), t = wx.getStorageSync("yz_basic_info").home.mailInfo.scribing_show && 1 == wx.getStorageSync("yz_basic_info").home.mailInfo.scribing_show ? 1 : 0;
            this.setData({
                language: e.en,
                scribing_show: t
            });
        },
        ready: function() {
            0 == Number(this.data.goodsInfo.market_price) ? this.data.goodsInfo.notMarket_price = 0 : this.data.goodsInfo.notMarket_price = 1;
            var o = wx.getStorageSync("yz_basic_info").lang.goods && wx.getStorageSync("yz_basic_info").lang.goods.price ? wx.getStorageSync("yz_basic_info").lang.goods.price : "", e = wx.getStorageSync("yz_basic_info").lang.goods && wx.getStorageSync("yz_basic_info").lang.goods.market_price ? wx.getStorageSync("yz_basic_info").lang.goods.market_price : "原价", t = wx.getStorageSync("integral");
            this.setData({
                integral: t || "积分",
                getMarketPrice: e,
                getprice: o,
                goods_plugin: this.data.plugin,
                goodsInfo: this.data.goodsInfo
            });
        }
    },
    data: {
        goods_plugin: {},
        isGoodsLove: !1,
        language: "",
        is_o2o: !1,
        goodsInfo: [],
        wechatcircle_open: 0,
        wx_video_link: 0,
        getMarketPrice: "",
        getprice: "",
        integral: "积分",
        showmoreTitle: !1,
        openVip: 2,
        available_coupon: [],
        riseFansPopup: !1,
        riseFansQrCode: ""
    },
    methods: {
        init: function(o) {
         
            e._isTextEmpty(o.plugin) || o.plugin.wechatcircle_open && 1 == o.plugin.wechatcircle_open && this.setData({
                wechatcircle_open: 1
            }), o.plugin && o.plugin.wx_video_link && this.setData({
                wx_video_link: o.plugin.wx_video_link
            });
        },
        getMemLevelInfo: function(o) {
            var e, t = {};
            o.member_discount.all_level_price.forEach(function(o) {
                o.is_select && (t = o), o.is_next && (e = o);
            }), this.setData({
                activeMemLevelInfo: t,
                lastMemLevelInfo: e
            });
        },
        setTitleState: function(o) {
            this.setData({
                showmoreTitle: !this.data.showmoreTitle
            });
        },
        goAdvtState: function() {
            this.data.goodsInfo.has_one_goods_advertising.min_link && wx.navigateTo({
                url: this.data.goodsInfo.has_one_goods_advertising.min_link
            });
        },
        gotoMemberGradeList: function(o) {
            "1" == o.currentTarget.dataset.flag && wx.navigateTo({
                url: "/packageB/member/MemberGradeList/MemberGradeList"
            });
        },
        setIsLove: function() {
            if (this.data.goods_plugin.goods_love) {
                var o = Number(this.data.goodsInfo.price) - Number(this.data.goods_plugin.goods_love.amountOfMoney);
                this.setData({
                    isGoodsLove: !0,
                    goods_love_cash: Number(o.toString().match(/^\d+(?:\.\d{0,2})?/)),
                    goods_love_deduction: this.data.goods_plugin.goods_love.amountOfCoin,
                    goods_love_name: this.data.goods_plugin.goods_love.name
                });
            } else this.setData({
                isGoodsLove: !1
            });
        },
        gotoCoupon: function() {
            if ("hotelGoods" == this.data.goodsType) return console.log(this.data.goods_info.hotel_id), 
            void wx.navigateTo({
                url: "/packageC/hotel/hotelCoupon/hotelCoupon?id=" + this.data.goods_info.hotel_id
            });
            wx.navigateTo({
                url: "/packageD/coupon/coupon_store"
            });
        },
        postShow: function() {
            this.triggerEvent("tapPostShow");
        },
        openShare: function() {
            this.triggerEvent("tapOpenShare");
        },
        onFavorite: function() {
            this.triggerEvent("onFavorite");
        },
        callhotelphone: function() {
            wx.makePhoneCall({
                phoneNumber: this.data.hotel_info.hotel_mobile
            });
        },
        hotelGetData: function(e) {
            this.data.enterAt && console.log(e.get_goods, e.get_hotel_info);
            var t = o(o({}, e.get_goods), e.get_hotel_info.goods);
            this.data.enterAt || wx.showModal({
                title: "提示",
                content: "选择入住酒店的时间?",
                success: function(o) {
                    o.confirm ? (e.get_hotel_info.goods.hotel_id && wx.navigateTo({
                        url: "/packageC/hotel/HotelHome/HotelHome?id=" + e.get_hotel_info.goods.hotel_id
                    }), console.log("用户点击确定")) : o.cancel && console.log("用户点击取消");
                }
            }), this.setData({
                goods_info: t,
                hotel_info: e.get_hotel_info.hotel,
                isGoods: !0
            });
        },
        setRiseFansPop: function() {
            this.setData({
                riseFansPopup: !this.data.riseFansPopup
            });
        },
        getFriendQrCode: function() {
            var o = this;
            if ("" == this.data.riseFansQrCode) {
                var t = e.getNetAddresss("plugin.discount-harvest-fans.frontend.controller.AddFriends.getFriendQrCode");
                e._getNetWork({
                    url: t,
                    data: {
                        goods_id: this.data.goodsInfo.id
                    },
                    success: function(t) {
                        var i = t.data;
                        if (1 != i.result) return e.tips(i.msg);
                        o.setData({
                            riseFansPopup: !0,
                            riseFansQrCode: i.data.qr_code
                        });
                    }
                });
            } else this.setRiseFansPop();
        }
    }
});